package com.ruoyi.eam.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.eam.doman.User;
import com.ruoyi.eam.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/users")
public class UserController extends BaseController {

    @Autowired
    private IUserService iUserService;


    //根据用户编号查找指定用户
    @GetMapping(value = "/{usePerson}")
    public AjaxResult getInfo(@PathVariable("usePerson") Long usePerson)
    {
        return success(iUserService.selectUserByUserId(usePerson));
    }

    //根据部门编号查找指定用户
    @GetMapping(value = "/seleDept/{deptId}")
    public AjaxResult selectUserByDeptId(@PathVariable("deptId") Long deptId){

        List<User>  list = iUserService.selectUserByDeptId(deptId);

        return success(list);
    }

    @GetMapping(value = "/list")
    public TableDataInfo selectUserList(User user){
        return getDataTable(iUserService.selectUserList(user));
    }
}
